package com.android.music.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

public class PeakValueView extends View {

	public static final int margin = 10;
	public static final int item_width = 50;

	private Paint paint = new Paint();

	private int[] left = new int[2];
	private int[] top = new int[2];
	private int[] right = new int[2];
	private int[] bottom = new int[2];

	public PeakValueView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public PeakValueView(Context context, AttributeSet attr) {
		super(context, attr);
		paint.setColor(Color.RED);
		paint.setStyle(Style.FILL);
	}
	
	public PeakValueView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}
	

	@SuppressLint("DrawAllocation") @Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		for (int i = 0; i < 2; i++) {	
			left[i] = margin;
			top[i] = margin + i * item_width * 2;
			right[i] = 100;// spectrum
			bottom[i] = top[i] + item_width;
			canvas.drawRect(new Rect(left[i], top[i], right[i], bottom[i]), paint);
		}
	}
}
